package com.sitech.ibnms.util.charts.fusion;

public class FusionMeterChart {

	public String getMeterChart(FusionMeterChartParam parameter) {
		return FusionChartCommon.getScript(parameter).replaceAll("######",
				this.setMeterChartParameter(parameter).toString());
	}

	public StringBuffer setMeterChartParameter(FusionMeterChartParam parameter) {
		StringBuffer chartParam = new StringBuffer();

		chartParam
				.append("<chart bgColor='"
						+ parameter.getBgColor()
						+ "' upperLimit='"
						+ parameter.getUpperLimit()
						+ "' lowerLimit='"
						+ parameter.getLowerLimit()
						+ "' baseFontColor='"
						+ parameter.getBaseFontColor()
						+ "' majorTMNumber='"
						+ parameter.getMajorTMNumber()
						+ "' majorTMColor='"
						+ parameter.getMajorTMColor()
						+ "' majorTMHeight='"
						+ parameter.getMajorTMHeight()
						+ "' minorTMNumber='"
						+ parameter.getMinorTMNumber()
						+ "' minorTMColor='"
						+ parameter.getMinorTMColor()
						+ "' minorTMHeight='"
						+ parameter.getMinorTMHeight()
						+ "' toolTipBorderColor='FFFFFF' toolTipBgColor='333333' gaugeOuterRadius='"
						+ parameter.getGaugeOuterRadius()
						+ "' gaugeOriginX='120' gaugeOriginY='120' gaugeScaleAngle='"
						+ parameter.getGaugeScaleAngle()
						+ "' placeValuesInside='1' gaugeInnerRadius='"
						+ parameter.getGaugeInnerRadius()
						+ "' annRenderDelay='0' gaugeFillMix='' pivotRadius='10' showPivotBorder='0' pivotFillMix='{CCCCCC},{333333}' pivotFillRatio='50,50' showShadow='0' pivotRadius='"
						+ parameter.getPivotRadius()
						+ "' showPivotBorder='"
						+ parameter.getShowPivotBorderString()
						+ "' pivotFillMix='{000000},{333333}' pivotFillRatio='50,50' showShadow='0' showBorder='"
						+ parameter.getShowBorder() + "'" + " numberPrefix='"
						+ parameter.getNumberPrefix() + "' numberSuffix='"
						+ parameter.getNumberSuffix() + "'>");

		chartParam
				.append("<colorRange><color minValue='0' maxValue='50' code='5DDE55' alpha='40'/><color minValue='50' maxValue='80' code='F5DF19' alpha='40'/><color minValue='80' maxValue='100' code='FF0000' alpha='40'/></colorRange>");

		chartParam
				.append("<dials><dial value='"
						+ parameter.getCurValue()
						+ "' borderColor='EEEEEE' bgColor='000000,CCCCCC,000000' borderAlpha='0' baseWidth='10'/></dials>");

		chartParam.append(getAnnotation(parameter));

		chartParam.append("</chart>");

		return chartParam;
	}

	public String getAnnotation(FusionMeterChartParam parameter) {
		StringBuffer chartParam = new StringBuffer();
		chartParam.append("<annotations>");
		chartParam
				.append("<annotationGroup id = '1' xPos='120' yPos='120' showBelow='1' >");

		chartParam
				.append("<annotation type='circle' xPos='0' yPos='0' radius='110' startAngle='0' endAngle='360' color='"
						+ parameter.getAnnotation_color() + "'/>");

		chartParam.append("</annotationGroup>");

		chartParam
				.append("<annotationGroup  id = '2'  xPos='120' yPos='120' showBelow='0'  link='n-"
						+ parameter.getUrl() + "'>");

		chartParam.append("<annotation xPos='0' yPos='60' type='text' label='"
				+ parameter.getLabel()
				+ "' fontColor='FF0000' fontSize='14' isBold='1'/>");

		chartParam.append("</annotationGroup>");

		chartParam.append("</annotations>");

		return chartParam.toString();
	}
}
